<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<div id="anchor-business-history" class="block-heading">
  <h5>过往业务信息</h5>
  
  <c:if test="${supplierMenuType != 'sub'}">
    <a href="${ctx.host}/suppliers/${supplier.id}/business-history/create?type=${param.type}" data-target="#create" data-toggle="modal" title="Edit"
       class="pull-right" style="font-size: 12px; padding-top: 20px;">新增</a>
  </c:if>
</div>

<table class="table table-hover ms-table ">
  <thead>
    <tr>
      <th>合同起止日期</th>
      <th>合同甲方</th>
      <th>合同乙方</th>
      <th>承运品牌</th>
      
      <c:if test="${param.type eq 'trans'}">
	      <th>出发地</th>
	      <th>目的地</th>
	      <th>投入运力板</th>
	      <th>月均运量</th>
	      <th>业务类型</th>
      </c:if>
      
      <c:if test="${param.type eq 'ware'}">
        <th>服务仓库所在地</th>  
	      <th>投入人员</th>
	      <th>月均业务量</th>
	      <th>业务类型</th>
      </c:if>
      
      <th>客户合同</th>
      
      <c:if test="${supplierMenuType != 'sub'}">
        <th class="text-center">操作</th>
      </c:if>
      
    </tr>
  </thead>
  
  <tbody>
    <c:forEach items="${supplierBusinessHistorys}" var="supplierBusinessHistory" varStatus="status"> 
	    <tr>
	      <td><fmt:formatDate value="${supplierBusinessHistory.startDate}" pattern="yyyy-MM-dd"/>&nbsp;&nbsp;-&nbsp;&nbsp;<fmt:formatDate value="${supplierBusinessHistory.endDate}" pattern="yyyy-MM-dd"/></td>
	      <td>${supplierBusinessHistory.consignor}</td>
	      <td>${supplierBusinessHistory.executor}</td>
	      <td>${empty supplierBusinessHistory.brand ? '无' : supplierBusinessHistory.brand}</td>
	      
	      <c:if test="${param.type eq 'trans'}">
		      <td>${empty supplierBusinessHistory.fromLoadPlace ? '无' : supplierBusinessHistory.fromLoadPlace}</td>
		      <td>${empty supplierBusinessHistory.toLoadPlace ? '无' : supplierBusinessHistory.toLoadPlace}</td>
		      <td>${empty supplierBusinessHistory.vehicleNum ? '无' : supplierBusinessHistory.vehicleNum}</td>
		      <td>${empty supplierBusinessHistory.averageCapacity ? '无' : supplierBusinessHistory.averageCapacity}</td>
		      <td>${empty supplierBusinessHistory.transType.description ? '无' : supplierBusinessHistory.transType.description}</td>
	      </c:if>
	      
	      <c:if test="${param.type eq 'ware'}">
		      <td>${empty supplierBusinessHistory.serviceLocation ? '无' : supplierBusinessHistory.serviceLocation}</td>
		      <td>${empty supplierBusinessHistory.staffNum ? '无' : supplierBusinessHistory.staffNum}</td>
		      <td>${empty supplierBusinessHistory.averageTraffic ? '无' : supplierBusinessHistory.averageTraffic}</td>
		      <td>${empty supplierBusinessHistory.wareType.description ? '无' : supplierBusinessHistory.wareType.description}</td>
	      </c:if>
	      
	      <td>
	        <c:choose>
	          <c:when test="${not empty supplierBusinessHistory.contractFile}">
	            <a href="${supplierBusinessHistory.contractFile}" download="${supplier.name}客户合同">客户合同</a>&nbsp;&nbsp;
	            <a class="text-danger" href="${ctx.host}/suppliers/${supplier.id}/business-history/${supplierBusinessHistory.id}/contract-upload?supplierMenuType=${param.supplierMenuType}" data-target="#upload" data-toggle="modal">重新上传</a>
	          </c:when>
	          <c:otherwise>
	            <a class="text-danger" href="${ctx.host}/suppliers/${supplier.id}/business-history/${supplierBusinessHistory.id}/contract-upload?supplierMenuType=${param.supplierMenuType}" data-target="#upload" data-toggle="modal">上传合同</a>
	          </c:otherwise>
	        </c:choose>
	      </td>
	      
	      <c:if test="${supplierMenuType != 'sub'}">
	        <td class="text-center">
	          <a href="${ctx.host}/suppliers/${supplier.id}/business-history/${supplierBusinessHistory.id}/edit?type=${param.type}" data-target="#edit" data-toggle="modal">修改</a>&nbsp;&nbsp;
	          <a href="${ctx.host}/suppliers/${supplier.id}/business-history/${supplierBusinessHistory.id }/delete" data-target="#delete" data-toggle="modal">删除</a>&nbsp;&nbsp;
	        </td>
	      </c:if>
	      
	    </tr>
    </c:forEach> 
  </tbody>
</table>